package com.friend.ui.util;

import android.content.Context;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.Registry;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.AppGlideModule;

import java.io.File;
import java.util.Objects;

/**
 * 作者： ch 时间： 2016/7/27.14:07 描述：glide 配置类 来源：
 */

@com.bumptech.glide.annotation.GlideModule
public class SimpleGlideModule extends AppGlideModule {


    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder glideBuilder) {

        String path = Objects.requireNonNull(context.getExternalCacheDir()).getPath();
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
        int cacheSize100MegaBytes = 104857600;
        glideBuilder.setDiskCache(new DiskLruCacheFactory(path, cacheSize100MegaBytes));

    }


    @Override
    public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {

    }

    @Override
    public boolean isManifestParsingEnabled() {
        return false;
    }
}
